package chapter02;

/**
 * 使用for循环输出杨辉三角
 * Created by a on 2017/6/9.
 */
public class Test034 {
    public static void main(String[] args) {

        int triangle[][] = new int[8][];
        //遍历数组的第一层
        for (int i = 0;i < triangle.length; i++){
            triangle[i] = new int[i+1];
            for (int j = 0;j<triangle[i].length;j++){
                if (i==0||j==0||j==triangle[i].length-1){
                    triangle[i][j] = 1;
                }else {
                    triangle[i][j] = triangle[i-1][j]+triangle[i][j-1];
                }
                System.out.println(triangle[i][j]);
            }
            System.out.println();
        }

    }
}
